package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchPumps;
import com.ruoyi.system.service.IDispatchPumpsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机泵信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchPumps")
public class DispatchPumpsController extends BaseController
{
    @Autowired
    private IDispatchPumpsService dispatchPumpsService;

    /**
     * 查询机泵信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumps:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchPumps dispatchPumps)
    {
        startPage();
        List<DispatchPumps> list = dispatchPumpsService.selectDispatchPumpsList(dispatchPumps);
        return getDataTable(list);
    }

    /**
     * 导出机泵信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumps:export')")
    @Log(title = "机泵信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchPumps dispatchPumps)
    {
        List<DispatchPumps> list = dispatchPumpsService.selectDispatchPumpsList(dispatchPumps);
        ExcelUtil<DispatchPumps> util = new ExcelUtil<DispatchPumps>(DispatchPumps.class);
        util.exportExcel(response, list, "机泵信息数据");
    }

    /**
     * 获取机泵信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumps:query')")
    @GetMapping(value = "/{pumpId}")
    public AjaxResult getInfo(@PathVariable("pumpId") Long pumpId)
    {
        return success(dispatchPumpsService.selectDispatchPumpsByPumpId(pumpId));
    }

    /**
     * 新增机泵信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumps:add')")
    @Log(title = "机泵信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchPumps dispatchPumps)
    {
        return toAjax(dispatchPumpsService.insertDispatchPumps(dispatchPumps));
    }

    /**
     * 修改机泵信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumps:edit')")
    @Log(title = "机泵信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchPumps dispatchPumps)
    {
        return toAjax(dispatchPumpsService.updateDispatchPumps(dispatchPumps));
    }

    /**
     * 删除机泵信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumps:remove')")
    @Log(title = "机泵信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pumpIds}")
    public AjaxResult remove(@PathVariable Long[] pumpIds)
    {
        return toAjax(dispatchPumpsService.deleteDispatchPumpsByPumpIds(pumpIds));
    }
}
